package com.yycx.module.pay.provider.utils;

import com.egzosn.pay.common.bean.PayOrder;
import com.yycx.module.pay.provider.response.PayResponse;

import javax.imageio.ImageIO;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * 支付工具类
 *
 * @author zyf
 */
public class PayUtils {

    /**
     * 获取支付二维码信息
     *
     * @param payResponse
     * @param payOrder
     * @return
     */
    public static byte[] getPayQrCode(PayResponse payResponse, PayOrder payOrder) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        try {
            ImageIO.write(payResponse.getService().genQrPay(payOrder), "JPEG", outputStream);
            return outputStream.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
